﻿using System.Linq.Expressions;
using Fuse8.DomainFramework.Domain;

namespace Fuse8.DomainFramework.DataAccess.SqlDatabase.Formatters
{
	internal class BooleanMemberExpressionFormattingService : IFormattingService
	{
		public object FormatObject(object obj, ExpressionType? parentExpressionType)
		{
			if ((parentExpressionType != ExpressionType.Equal && parentExpressionType != ExpressionType.NotEqual))
			{
				return string.Format("({0} = 1)", obj);
			}
			return obj;
		}

		public Expression CreateFormatDelegate(Expression expression, ExpressionType? parentExpressionType)
		{
			return expression;
		}
	}
}